//package com.qcby.pushservice.web.controller;
//
//import cn.hutool.core.bean.BeanUtil;
//import cn.hutool.core.util.ObjectUtil;
//import com.qcby.pushservice.base.dto.DemoDTO;
//import com.qcby.pushservice.client.params.TestParam;
//import com.qcby.pushservice.web.entity.param.DemoParam;
//import com.qcby.pushservice.web.entity.vo.DemoVO;
//import com.qcby.framework.common.exception.ServiceException;
//import com.qcby.framework.common.pojo.PageParam;
//import com.qcby.framework.common.pojo.PageResult;
//import com.qcby.framework.common.pojo.Result;
//import com.qcby.pushservice.client.TestFacade;
//import com.qcby.pushservice.client.dto.TestDTO;
//import com.qcby.pushservice.web.exchange.AutoHandExchange;
//
//import com.qcby.pushservice.base.service.ITestService;
//import com.qcby.pushservice.client.PushFacade;
//import com.qcby.pushservice.client.dto.PushSmsDTO;
//import com.qcby.pushservice.client.param.SendParams;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.dubbo.config.annotation.DubboReference;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.web.bind.annotation.*;
//
//import javax.annotation.Resource;
//import javax.validation.constraints.NotNull;
//import java.util.ArrayList;
//import java.util.Date;
//import java.util.HashMap;
//import java.util.List;
//
//
///**
// * 测试控制器
// *
// * @author cong.zhen
// * @date 2023/04/11
// */
//@RestController
//@RequestMapping("test-system/exam")
//@Slf4j
//public class TestController {
//
//    /**
//     * 考试时长，单位毫秒
//     */
//    @Value("${test.time}")
//    private Long examTime;
//
//
//
//
//    @DubboReference
//    private PushFacade pushFacade;
//
//    @Resource
//    private ITestService testService;
//
//    @PostMapping("/start-test")
//    public Result<Boolean> startTest(@RequestBody DemoParam demoParam){
//        DemoDTO demoDTO = BeanUtil.copyProperties(demoParam,DemoDTO.class);
//        //只要开始考试，就从延时队列里放一条数据
//        log.info("配置的考试时长为:{}",examTime);
//        demoDTO.setCreateTime(new Date());
//        demoDTO.setTestTime(examTime);
//        AutoHandExchange.getDelayQueue().add(demoDTO);
//        return Result.getSuccessResult(Boolean.TRUE);
//    }
//
//
//    @GetMapping("/page-query")
//    public Result<PageResult<DemoVO>> pageQuery(DemoParam demoParam, PageParam pageParam){
//        DemoDTO demoDTO = BeanUtil.copyProperties(demoParam,DemoDTO.class);
//        Result<PageResult<DemoDTO>> pageResultResult = testService.demoPageQuery(demoDTO, pageParam);
//        /**dto转vo**/
//        List<DemoVO> demoVOS = BeanUtil.copyToList(pageResultResult.getData().getList(), DemoVO.class);
//        /**构造返回对象**/
//        PageResult<DemoVO> pageResult = new PageResult();
//        pageResult.setTotal(pageResultResult.getData().getTotal());
//        pageResult.setList(demoVOS);
//        return Result.getSuccessResult(pageResult);
//    }
//
//    @GetMapping("/person-detail")
//    public Result<DemoVO> getDetail(@NotNull Long id){
//        DemoDTO demoById = testService.getDemoById(id);
//        return Result.getSuccessResult(BeanUtil.copyProperties(demoById,DemoVO.class));
//    }
//
//    @PostMapping("/edit-person")
//    public Result<Boolean> editById(@RequestBody DemoParam demoParam){
//        /**参数校验**/
//        if(ObjectUtil.isNull(demoParam.getId())){
//            throw new ServiceException("500","id不能为空");
//        }
//        DemoDTO demoDTO = BeanUtil.copyProperties(demoParam,DemoDTO.class);
//        return Result.getSuccessResult(testService.saveOrUpdate(demoDTO));
//    }
//
//    @PostMapping("/save-person")
//    public Result<Boolean> savePerson(@RequestBody DemoParam demoParam){
//        if(ObjectUtil.isNotNull(demoParam.getId())){
//            throw new ServiceException("500","参数有误");
//        }
//        DemoDTO demoDTO = BeanUtil.copyProperties(demoParam,DemoDTO.class);
//        return Result.getSuccessResult(testService.saveOrUpdate(demoDTO));
//    }
//
//    @GetMapping("remove-person")
//    public Result<Boolean> removeById(@NotNull Long id){
//        return Result.getSuccessResult(testService.removeById(id));
//    }
//
//
////    @GetMapping("/dubbo-test")
////    public Result<Long> testDubbo(){
////        TestParam testParam = new TestParam();
////        testParam.setAge(10);
////        testParam.setId(1L);
////        testParam.setName("甄聪");
////        TestDTO dto = testFacade.testDubbo(testParam);
////        return Result.getSuccessResult(dto.getId());
////    }
//
//    @GetMapping("/hello")
//    public String hello() {
//        SendParams sendParams = new SendParams();
//        HashMap<String,String> map = new HashMap<>(2);
//        map.put("name","甄聪");
//        map.put("age","24");
//        sendParams.setMaps(map);
//        PushSmsDTO pushSmsDTO = pushFacade.sendSms(sendParams);
//        return String.valueOf(pushSmsDTO);
//
//    }
//
//
//
//
//}
